// <!-- 企业采购二级菜单显示 -->
function clickqycg() {
    var san = document.getElementsByClassName("san1")[0];
    var qycgcon = document.getElementsByClassName("qycgcon")[0];

    san.style.display = "block";
    qycgcon.style.display = "flex";
}
// <!-- 企业采购二级菜单隐藏 -->
function hideqycg() {
    var san = document.getElementsByClassName("san1")[0];
    var qycgcon = document.getElementsByClassName("qycgcon")[0];

    san.style.display = "none";
    qycgcon.style.display = "none";
}
// <!-- 客户服务二级菜单显示 -->
function clickkffw() {
    var kf = document.getElementsByClassName("kf1")[0];
    var kffwcon = document.getElementsByClassName("kffwcon")[0];

    kf.style.display = "block";
    kffwcon.style.display = "flex";
}
// <!-- 客户服务二级菜单隐藏 -->
function hidekffw() {
    var kf = document.getElementsByClassName("kf1")[0];
    var kffwcon = document.getElementsByClassName("kffwcon")[0];

    kf.style.display = "none";
    kffwcon.style.display = "none";
}
// app手机下载显示
function clickapp() {
    var ap = document.getElementsByClassName("ap1")[0];
    var appbox = document.getElementsByClassName("appbox")[0];

    ap.style.display = "block";
    appbox.style.display = "flex";
}
// app手机下载隐藏
function hideapp() {
    var ap = document.getElementsByClassName("ap1")[0];
    var appbox = document.getElementsByClassName("appbox")[0];

    ap.style.display = "none";
    appbox.style.display = "none";
}

// 新品首发
// 上一页
var smallupbox = document.querySelector('.smallupbox');
var smallnextbox = document.querySelector('.smallnextbox');
var moduleconview = document.querySelector('.moduleconview');
var viewbox = document.querySelectorAll('.viewbox');
var count = 0;
smallupbox.addEventListener("click", () => {
    if (count !== 0) {
        count--;
        moduleconview.style.left = parseInt(moduleconview.style.left) + 1100 + 'px'
    }

})
smallnextbox.addEventListener("click", () => {
    if (count !== viewbox.length - 1) {
        count++;
        moduleconview.style.left = parseInt(moduleconview.style.left) - 1100 + 'px'
    }
})

// 人气推荐
// 点击显示
var rq=document.querySelectorAll('.rq');
var bjtjbox=document.querySelector('.bjtjbox');
var rxzbbox=document.querySelector('.rxzbbox');
function showshop(n){
    for(var i=0;i<rq.length;i++){
        rq[i].style.color='#333';
        rq[i].style.borderBottom="none";
    }
    rq[n].style.color='#b4a078';
    rq[n].style.borderBottom="2px solid #b4a078";
    if(n==0){
        bjtjbox.style.display='flex';
        rxzbbox.style.display='none';
    }
    if(n==1){
        bjtjbox.style.display='none';
        rxzbbox.style.display='flex';
    }
}


// 滚轴
var ceilingbox = document.getElementsByClassName("ceilingbox")[0];
var leftstickybox = document.getElementsByClassName("leftstickybox")[0];
var rightstickybox = document.getElementsByClassName("rightstickybox")[0];
var back = document.getElementsByClassName("back")[0];
window.onscroll = function () {
    if (window.scrollY > 117) {
        ceilingbox.style.height = 50 + 'px';
    } else if (window.scrollY < 117) {
        ceilingbox.style.height = 0;
    }
    if (window.scrollY > 600) {
        leftstickybox.style.position = "fixed";
        leftstickybox.style.top = 62 + "px";
        rightstickybox.style.position = "fixed";
        rightstickybox.style.top = 62 + "px";
    } else {
        leftstickybox.style.position = "absolute";
        leftstickybox.style.top = 0;
        rightstickybox.style.position = "absolute";
        rightstickybox.style.top = 0;
    }
    if (window.scrollY > 900) {
        back.style.height = 57 + 'px';
    } else {
        back.style.height = 0;
    }
}
// 回到顶部
function backscroll() {
    window.scrollTo(0, 0)
}
// 底部自动播放轮播图
var num = 0
var bannerview = document.querySelector(".bannerview");
var bannercon = document.querySelectorAll(".bannercon");
var nextbox = document.querySelector(".nextbox");
var upbox = document.querySelector(".upbox");
function swiperbox() {
    bannerview.style.transition = 'left 0.3s'
    num++;
    bannerview.style.left = parseInt(bannerview.style.left) - 370 + 'px';
    if (num == 6) {
        setTimeout(() => {
            bannerview.style.transition = 'none'
            bannerview.style.left = -1110 + 'px';
            num = 0
        }, 300);
    }
}
nextbox.addEventListener('click', () => {
    swiperbox();
})
upbox.addEventListener('click', () => {
    bannerview.style.transition = 'left 0.3s';
    num--;
    bannerview.style.left = parseInt(bannerview.style.left) + 370 + 'px';
    if (num == -1) {
        setTimeout(() => {
            bannerview.style.transition = 'none';
            bannerview.style.left = -2220 + 'px'
            num = 5;
        }, 300);

    }
})
function playswiper() {
    setInterval(() => {
        swiperbox();
    }, 2000)
}
playswiper();